Page({
  data: {
    questionnaires: [],
    loading: true,
    currentTab: 'all', // all, unfinished, finished
  },

  onLoad() {
    // 使用模拟数据
    const mockQuestionnaires = [
      {
        id: '1',
        title: '睡眠质量评估问卷V2.0',
        version: '2.0',
        createTime: '2024-03-21',
        estimatedTime: 5,
        status: 'unfinished'
      },
      {
        id: '2',
        title: '睡眠习惯调查问卷',
        version: '1.0',
        createTime: '2024-03-20',
        estimatedTime: 3,
        status: 'finished'
      },
      {
        id: '3',
        title: '睡眠环境评估问卷',
        version: '1.0',
        createTime: '2024-03-19',
        estimatedTime: 4,
        status: 'unfinished'
      }
    ];

    // 模拟加载延迟
    setTimeout(() => {
      this.setData({
        questionnaires: mockQuestionnaires,
        loading: false
      });
    }, 500);
  },

  onPullDownRefresh() {
    // 模拟刷新
    setTimeout(() => {
      wx.stopPullDownRefresh();
    }, 500);
  },

  switchTab(e) {
    const tab = e.currentTarget.dataset.tab;
    this.setData({ currentTab: tab });
  },

  navigateToDetail(e) {
    const { id } = e.currentTarget.dataset;
    wx.navigateTo({
      url: `/pages/questionnaire/detail/index?id=${id}`
    });
  }
}); 